<!-- wyf 2022-3-1 -->
<template>
  <a-menu
    :ref="menuRef"
    v-model:openKeys="openKeys1"
    v-model:selectedKeys="selectedKeys1"
    :mode="mode"
    :theme="theme"
    :force-sub-menu-render="forceSubMenuRender"
    :inline-collapsed="inlineCollapsed"
    :inline-indent="inlineIndent"
    :multiple="multiple"
    :selectable="selectable"
    :sub-menu-close-delay="subMenuCloseDelay"
    :sub-menu-open-delay="subMenuOpenDelay"
    :overflowed-indicator="overflowedIndicator"
    :trigger-sub-menu-action="triggerSubMenuAction"
  >
    <template v-if="$slots.title" #title>
      <slot name="title" />
    </template>
    <template v-if="$slots.switcherIcon" #switcherIcon>
      <slot name="switcherIcon" />
    </template>
    <slot />
  </a-menu>
</template>

<script>
import { defineComponent, computed } from 'vue'
import { Menu } from 'ant-design-vue'
export default defineComponent({
  name: 'ZMenu',
  components: {
    AMenu: Menu
  },
  props: {
    menuRef: {
      type: String,
      default: 'menu'
    },
    openKeys: {
      type: Array,
      default() {
        return []
      }
    },
    selectedKeys: {
      type: Array,
      default() {
        return []
      }
    },
    mode: {
      type: String,
      default: 'inline'
    },
    theme: {
      type: String,
      default: 'light'
    },
    forceSubMenuRender: {
      type: Boolean,
      default: false
    },
    inlineCollapsed: {
      type: Boolean,
      default: undefined
    },
    inlineIndent: {
      type: Number,
      default: 24
    },
    multiple: {
      type: Boolean,
      default: false
    },
    selectable: {
      type: Boolean,
      default: true
    },
    subMenuCloseDelay: {
      type: Number,
      default: 0.01
    },
    subMenuOpenDelay: {
      type: Number,
      default: 0
    },
    overflowedIndicator: {
      type: Function,
      default: undefined
    },
    triggerSubMenuAction: {
      type: String,
      default: 'hover'
    }
  },
  setup(props, _ref) {
    const openKeys1 = computed({
      get() {
        return props.openKeys
      },
      set(val) {
        _ref.emit('update:openKeys', val)
      }
    })
    const selectedKeys1 = computed({
      get() {
        return props.selectedKeys
      },
      set(val) {
        _ref.emit('update:selectedKeys', val)
      }
    })
    return {
      openKeys1,
      selectedKeys1
    }
  }
})
</script>
